package com.zhudeshuai.zhudemolist.activity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import com.zhu.zhuCore.utils.EmptyUtil;
import com.zhu.zhuCore.utils.ToastUtil;
import com.zhudeshuai.zhudemolist.R;
import com.zhudeshuai.zhudemolist.base.BaseActivity;

/**
 * Intent测试工具类
 *
 * @author zhudeshuai
 * @since 2018/8/9
 */
public class IntentTest extends BaseActivity {

	private EditText mEditText;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_intent_test);
		mEditText = (EditText) findViewById(R.id.et);
	}

	public void onInvoke(View view) {
		String s = mEditText.getText().toString();
		if (EmptyUtil.isEmpty(s)) {
			ToastUtil.show("scheme不能为空");
		} else {
			Uri data = Uri.parse(s);
			Intent intent = new Intent(Intent.ACTION_VIEW, data);
			intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			try {
				startActivity(intent);
			} catch (Exception e) {
				e.printStackTrace();
			}

		}
	}
}
